package com.example.shiro_demo1.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * @author cxp
 * @version 1.0
 * @date 2019/7/1 10:51
 */
public class SaltUtil {
    public static void main(String[] args) {
        //盐：为了即使相同的密码不同的盐加密后的结果也不同
        //随机生成盐值
        ByteSource salt1 = ByteSource.Util.bytes("admin");
        //加密方式
        String hashAlgorithmName = "MD5";
        //密码
        String source = "123456";
        //加密次数
        int hashIterations = 1024;
        SimpleHash result = new SimpleHash(hashAlgorithmName, source, salt1, hashIterations);
        System.out.println(result.toHex());
    }
}
